package com.linked.basemanage.pass.service.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.linked.basemanage.pass.bean.param.AddPassInfoParam;
import com.linked.basemanage.pass.bean.po.PassInfoPO;
import com.linked.basemanage.pass.mapper.IPassInfoMapper;
import com.linked.basemanage.pass.service.IPassHandleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :dbq
 * @date : 2023/3/24 14:57
 * @description : desc
 */
@Slf4j
@Service
public class PassHandleServiceImpl implements IPassHandleService {

    private final ObjectMapper mapper;

    private final IPassInfoMapper passInfoMapper;

    public PassHandleServiceImpl(ObjectMapper mapper, IPassInfoMapper passInfoMapper) {
        this.mapper = mapper;
        this.passInfoMapper = passInfoMapper;
    }

    @Override
    public boolean addPassInfo(AddPassInfoParam param) throws Exception {
        PassInfoPO pass = new PassInfoPO(param);
        return passInfoMapper.insert(pass) > 0;
    }

    @Override
    public List<String> queryBlackList() {
        return passInfoMapper.queryPassListByType(2);
    }

    @Override
    public List<String> queryWihteList() {
        return passInfoMapper.queryPassListByType(1);
    }
}
